Ví dụ Ngôn_ngữ_trung_gian_dùng_chung

Dưới đây là chương trình Hello, World được viết trong CIL:

.assembly Hello {}.assembly extern mscorlib {}.method static void Main(){  .entrypoint  .maxstack 1  ldstr "Hello, world!"  call void [mscorlib]System.Console::WriteLine(string)  ret}

Chương trình sau sử dụng các dạng số phức tạp hơn của opcode

Đoạn mã này cũng có thể được so sánh với đoạn mã tương ứng trong bài viết về Java bytecode.

static void Main(string[] args){  for (int i = 2; i < 1000; i++)  {  for (int j = 2; j < i; j++)  {   if (i % j == 0)   goto outer;  }  Console.WriteLine(i);  outer:;  }}

Trong CIL, chương trình trên trở thành:

.method private hidebysig static void Main(string[] args) cil managed{  .entrypoint  .maxstack 2  .locals init (int32 V_0,   int32 V_1)   ldc.i4.2   stloc.0   br.s  IL_001f  IL_0004: ldc.i4.2   stloc.1   br.s  IL_0011  IL_0008: ldloc.0   ldloc.1   rem   brfalse.s IL_001b   ldloc.1   ldc.i4.1   add   stloc.1  IL_0011: ldloc.1   ldloc.0   blt.s IL_0008   ldloc.0   call  void [mscorlib]System.Console::WriteLine(int32)  IL_001b: ldloc.0   ldc.i4.1   add   stloc.0  IL_001f: ldloc.0   ldc.i4 0x3e8   blt.s IL_0004   ret}